export default {
    namespaced: true,
    state: {
        // 下拉菜单的数据
        poweredit: [{
            bool: false,
            name: '客服录入新增',
            path: 'v1/clue/user/create'
        }, ],
        modules: [], // 角色模块
        menuIds: [], // 角色权限
        actionIds: [], // 角色动作
    },
    getters: {
        /**
         * @description 获取下拉菜单
         * */
        selectInfoObj(state) {
            return state.poweredit;
        },
    },
    mutations: {
        /**
         * @description 设置下拉菜单数据
         * @param {Object} state vuex state
         * @param {Array} menu menu
         */
        setSelectInfo(state, poweredit) {
            state.poweredit = poweredit;
        },
        setEditpower(state, poweredits) {
            let states = JSON.parse(JSON.stringify(state.poweredit));
            for (let item of states) {
                if (item.path === poweredits) {
                    item.bool = true;
                }
            }
            state.poweredit = states;
        },
        // 角色模块
        Addmodules(state, value) {
            // console.log(state, 'state');
            // console.log(value, 'value');
            state.modules = value;
            // state.modules.push(value);
        },
        // 角色菜单
        AddmenuIds(state, value) {
            state.menuIds = value;
            // state.menuIds.push(value);
        },
        // 角色动作
        AddactionIds(state, value) {
            state.actionIds = value;
            // state.actionIds.push(value);
        },
        AelectPermissonList(state, value) {
            state.aelectPermissonList = value;
            // state.actionIds.push(value);
        },
    },
    actions: { // 异步触发mutations里的方法
        modulesAsync(context, value) {
            // console.log(value, '1111va');
            context.commit('Addmodules', value); // 异步触发
        },
        menuIdsAsync(context, value) {
            context.commit('AddmenuIds', value); // 异步触发
        },
        actionIdsAsync(context, value) {
            context.commit('AddactionIds', value); // 异步触发
        },

    },
};